#pragma once

class DeleteUserHandler : public JsonRequest<DeleteUserHandler> 
{
public:
	bool response()
	{
		std::string		gid;
		std::string		uid;
		sql_string<>	sql;

		if(false == request::get("gid", gid)
				|| false == request::get("uid", uid))
		{
			err << "invalid paramter";
			return false;
		}
		
		sql.format("delete from t_users where gid=%d and uid=%d",
				atoi(gid.c_str()), atoi(uid.c_str()));
		if(1 != sql::execute(sql.c_str()))
		{
			err << "delete uid failed:"
				<< sql.c_str();
			return false;
		}
		
		json.push_back(JSONNode("errno", 0));
		return true;
	}
};
